import Vue from 'vue'
import VueRouter from 'vue-router'
import Films from '../views/Films'
import Aritcle from '../views/Article'
import Center from '../views/Center'
import MovieDetail from '../views/Films/MovieDetail.vue'
import Detail from '../views/Detail/Movetz.vue'
import Detailto from '../views/Detailto/index.vue'
// 嵌套路由的设置 引入路由
import Nowplaying from '../views/Films/children/Nowplaying.vue'
import ComingSoon from '../views/Films/children/ComingSoon.vue'
import Detailtop from '../views/Detailtop/index.vue'
import City from '../views/City/index'

Vue.use(VueRouter)
Vue.filter("handleString",function(val){
  if(val.length>18){
    val = val.slice(0,19)+"..."
  }
  return val
  })

const routes = [
  {
    path:"/",
    redirect:"/films"
  },
  {
    path: '/films',
    name: 'Films',
    component:Films,
    meta:{
      isNav:true
    },
    children:[
      {
        path:"nowPlaying",
        component:Nowplaying,
        meta:{
          isNav:true
        },
      },{
        path:"comingsoon",
        component:ComingSoon,
        meta:{
          isNav:true
        },
      }
    ]
  },
  {
    path: '/article',
    name: 'About',
    component:Aritcle,
    meta:{
      isNav:true
    }
  },{
    path:"/center",
    name:"Center",
    component:Center,
    meta:{
      isNav:true
    }
  },{
    path:"/movie/:id",
    name:"MovieDetail",
    component:MovieDetail
  },{
    path:"/detail/:id",
    name:"Detail",
    component:Detail,
    meta:{
      isNav:true
    }
  },{
    path:"/detailto/:id",
    name:"Detailto",
    component:Detailto,
    meta:{
      isNav:true
    }
  },{
    path:"/detailtop/:id",
    name:"Detailtop",
    component:Detailtop,
    meta:{
      isNav:true
    }
  },{
    path:"/city/:text",
    name:"City",
    component:City
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
